/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package r.util;

import java.util.List;

/**
 *
 * @author jcrada
 */
public class Eval {

    public static String Repeat(Object x, int times, String sep) {
        String result = "";

        for (int i = 0; i < times; ++i) {
            result += x.toString();
            if (i < times - 1) {
                result += sep;
            }
        }

        return result;
    }

    public static String ToString(List list, String sep) {
        return ToString(list, "", "", sep);
    }
    
    public static String ToString(List list, String prefix, String postfix, String sep) {
        String result = "";
        for (int i = 0; i < list.size(); ++i) {
            result += prefix + list.get(i).toString() + postfix;
            if (i < list.size() - 1) {
                result += sep;
            }
        }
        return result;
    }
}
